package org.lansir.af.model;

import org.lansir.af.gtalk.service.Contact;

import android.os.Parcel;
import android.os.Parcelable;

public class ActivityMessageItem implements Parcelable {
	public enum MsgType{
		SMS, OTHER
	}
	
	private MsgType type;
	private String body;
	private Contact contact;
	
	public static final Parcelable.Creator<ActivityMessageItem> CREATOR = new Parcelable.Creator<ActivityMessageItem>() {

		@Override
		public ActivityMessageItem createFromParcel(Parcel source) {
			return new ActivityMessageItem(source);
		}

		@Override
		public ActivityMessageItem[] newArray(int size) {
			return new ActivityMessageItem[size];
		}
	};
	
	
	
	public ActivityMessageItem(MsgType type, String body, Contact contact) {
		super();
		this.type = type;

		this.body = body;
		this.contact = contact;

	}

	private ActivityMessageItem(final Parcel in) {
		type = in.readInt()==0?MsgType.SMS:MsgType.OTHER;

		body = in.readString();
		contact = in.readParcelable(Contact.class.getClassLoader());
	}
	
	public MsgType getType() {
		return type;
	}
	public void setType(MsgType type) {
		this.type = type;
	}

	public String getBody() {
		return body;
	}
	public void setBody(String body) {
		this.body = body;
	}
	
	
	
	public Contact getContact() {
		return contact;
	}

	public void setContact(Contact contact) {
		this.contact = contact;
	}

	@Override
	public int describeContents() {
		
		return 0;
	}
	
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(type==MsgType.SMS?0:1);
		dest.writeString(body);
		dest.writeParcelable(contact, flags);
	}
	
	
}
